package com.example.wishstar.view.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModel;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.wishstar.MainActivity;
import com.example.wishstar.R;
import com.example.wishstar.databinding.ActivityRegisterBinding;
import com.example.wishstar.databinding.ActivityUpdateUserMsgBinding;
import com.example.wishstar.databinding.FragmentUsersBinding;
import com.example.wishstar.viewmodel.RegisterViewModel;
import com.example.wishstar.viewmodel.UpdateUserMsgViewModel;

public class UpdateUserMsgActivity extends AppCompatActivity {
    private String TAG = "UpdateUserMsgActivity";
    private UpdateUserMsgViewModel updateUserMsgViewModel;
    private String  nickname;
    private String motto;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_update_user_msg);

        Bundle bundle = this.getIntent().getExtras();
        nickname = bundle.getString("nickname");
        motto = bundle.getString("motto");
        Log.e(TAG, "" + nickname);
        Log.e(TAG, "" + motto);

        ActivityUpdateUserMsgBinding activityUpdateUserMsgBinding = DataBindingUtil.setContentView(this, R.layout.activity_update_user_msg);
        updateUserMsgViewModel = new UpdateUserMsgViewModel(this);
        activityUpdateUserMsgBinding.setUpdateUserMsgViewModel(updateUserMsgViewModel);

        updateUserMsgViewModel.setNickname(nickname);
        updateUserMsgViewModel.setMotto(motto);

        TextView title = findViewById(R.id.back_title);
        title.setText("修改个人信息");

        ImageView backImage = findViewById(R.id.image_title_back);

        backImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(UpdateUserMsgActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
            }
        });

    }
}